<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>


<script>
  window.addEventListener('DOMContentLoaded', () => {
    const navBox = document.getElementById('navBox');

    /** 渲染队列机制: */

    // 下面两行改变样式的代码 只会触发一次回流
    // navBox.style.width = '100px';
    // navBox.style.height = '100px';
    // console.log(navBox.clientWidth);

    // 以下情况会触发两次回流(读写不分离)
    navBox.style.width = '100px'; // 写
    console.log(navBox.clientWidth); // 读
    navBox.style.height = '100px';
    /* 以下这些获取样式的属性都会导致立即触发回流
      offsetTop、offsetLeft、offsetWidth、offsetHeight、clientTop、clientLeft、clientWidth、clientHeight、scrollTop、scrollLeft、scrollWidth、scrollHeight、getComputedStyle、currentStyle ...
    */
  });
</script>
</body>
</html>
